package cn.wjzhang;

import cn.wjzhang.config.NavProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Objects;

/**
* @author pig archetype
* <p>
* 项目启动类
*/
@SpringBootApplication
@EnableConfigurationProperties({ NavProperties.class })
@Slf4j
public class WjNavApplication {

    public static void main(String[] args) throws UnknownHostException {
        ApplicationContext ctx = SpringApplication.run(WjNavApplication.class, args);
        Environment env = ctx.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = Objects.isNull(env.getProperty("server.servlet.context-path")) ? "" : env.getProperty("server.servlet.context-path");
        log.info("\n----------------------------------------------------------\n\t" +
                "凝夜紫导航 is running! Access URL:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "\n\t" +
                "----------------------------------------------------------");    }

}
